﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace G.WeiBo
{
    public class APPConfig : INotifyPropertyChanged
    {
        public const string SaveTokenName = "sina_token";

        private static APPConfig instance;
        public static APPConfig Instance
        {
            get
            {
                if (instance == null)
                    instance = new APPConfig();
                return instance;
            }
        }

        private APPConfig()
        {
            //WebAPI.APIConfig.IsLoadPic = this.IsLoadPic;
        }

        ///// <summary>
        ///// 是否自动判断加载图片
        ///// </summary>
        //public bool IsAutoLoadPic
        //{

        //}

        private bool? isLoadPic;
        public bool IsLoadPic
        {
            get
            {
                if (isLoadPic == null)
                {
                    if (System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Contains("weibo_isLoadPic"))
                    {
                        isLoadPic = (bool)System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings["weibo_isLoadPic"];
                    }
                    else
                    {
                        isLoadPic = true;
                    }
                }
                return isLoadPic.Value;
            }
            set
            {

                isLoadPic = value;
                System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings["weibo_isLoadPic"] = value;
                System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Save();
                WebAPI.APIConfig.IsLoadPic = value;
                this.NotifyChanged("IsLoadPic");
            }
        }

        //private int globalPageSize;
        //public int GlobalPageSize
        //{
        //    get
        //    {
        //        return globalPageSize;
        //    }
        //    set
        //    {
        //        this.globalPageSize = value;
        //    }
        //}

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyChanged(string name)
        {
            if (this.PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }
    }
}
